//当前这个模块：API进行统一管理
import requests from './requests';

//三级联动接口
//  /api/product/getBaseCategoryList  get 无参数
//发请求：axios发请求返回结果Promise对象
// export const reqCategoryList = ()=>requests({url:'product/getBaseCategoryList',method:'get'});

//注册接口
// export const reqRegister = (data)=>requests({url:`/blog/user/register`,method:'post',data});
export function reqRegister(username,password){
    const registermessage = new FormData();
    registermessage.append("username",username);
    registermessage.append("password",password)
    return requests({
        url:'/blog/user/register',
        method:'post',
        data:registermessage
    })
}
//登录接口
// export const reqUserLogin = (data)=>requests({url:`/blog/user/login`,method:'post',data});
export function reqUserLogin(username,password){
    const loginmessage = new FormData();
    loginmessage.append("username",username);
    loginmessage.append("password",password)
    return requests({
        url:'/blog/user/login',
        method:'post',
        data:loginmessage
    })
}
//获取用户登录成功以后用户信息的接口
export const reqUserInfo = ()=>requests({url:`/blog/user/userInfo`,method:'get'});
// export function getUserInfo() {
//     return requests({
//       url: '/blog/user/userInfo',
//       method: 'get'
//     })
//   }
//退出登录业务
// export const reqUserLogout = ()=>requests({url:`/blog/user/logout`,method:'get'});

//上传文章
export function upArticle(title,classify,synopsis,tags,html,date){
  console.log("-----------------",title,classify,synopsis,tags,html,date)
  const article = new FormData();
  article.append("article","测试");
  article.append("title","测试");
  article.append("classify","测试");
  article.append("date","测试");
  article.append("synopsis","测试");
  article.append("tags","ceshi");

console.log(article)
    return requests({
      url: '/blog/user/uploadarticle',
      method: 'get',
      // headers:{'Content-type' : 'multipart/form-data;boundary=-----wefwegagagagat''},
      data: article
    })
  }

//上传图片
export function upImg(imgData){
    console.log(imgData)
    return requests({
      url: '/blog/user/uploadimg',
      method: 'post',
      // headers:{'Content-type' : 'multipart/form-data;boundary=-----wefwegagagagat''},
      data: imgData
    })
  }